! function(a) {
	a.extend({
		carousel: function(b) {
			var c, d, e, f, g = a("#slidebar"),
				h = g.find("li.sel"),
				i = g.find("a.prev"),
				j = g.find("a.next"),
				k = {
					interval: b && b.interval || 3500,
					animateTime: b && b.animateTime || 500,
					direction: b && "right" === b.direction,
					len: h.length
				},
				l = 0,
				m = function(a) {
					return l + a >= k.len ? l + a - k.len : l + a
				},
				n = function(a) {
					return 0 > l - a ? k.len + l - a : l - a
				},
				o = function(b) {
					function g() {
						a(".iphoto_div h2").length > 0 && (a(".iphoto_div h2").html(), a(".iphoto_div")
							.empty(), a(".iphoto_div").append(d, e, f)), a(".iphoto_div h2").html(h.eq(
							l).find("a").attr("title")), a(".iphoto_div p").html(h.eq(l).find("img")
							.attr("alt"))
					}
					h.eq(b ? n(2) : m(2)).css("left", (b ? "-" : "+") + "2400px"), h.animate({
						left: (b ? "+" : "-") + "=1200px"
					}, k.animateTime), l = b ? n(1) : m(1), g()
				},
				p = setInterval(function() {
					o(k.direction)
				}, k.interval);
			h.eq(l).css("left", 0).end().eq(l + 1).css("left", "1200px").end().eq(l - 1).css("left",
					"-1200px"), g.find(".show").add(i).add(j).hover(function() {
					clearInterval(p)
				}, function() {
					p = setInterval(function() {
						o(k.direction)
					}, k.interval)
				}), c = document.createElement("div"), d = document.createElement("h2"), e = document
				.createElement("p"), f = document.createElement("span"), c.setAttribute("class",
					"iphoto_div"), g.children().append(c), a(c).append(d, e, f), a(c).children("h2").html(h
					.eq(l).find("a").attr("title")), a(c).children("p").html(h.eq(l).find("img").attr(
					"alt")), i.click(function() {
					0 === a(":animated").length && o(!0)
				}), j.click(function() {
					0 === a(":animated").length && o(!1)
				})
		}
	})
}(jQuery);
